package com.game.my2048;
import android.content.Context;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;

/**
 * Created by Administrator on 16-8-16.
 */
public class Card extends FrameLayout{


    public Card(Context context) {
        super(context);
        label = new TextView(getContext());
        label.setTextSize(32);
        label.setBackgroundColor(0x33ffffff);
        label.setGravity(Gravity.CENTER);

        LayoutParams lp = new LayoutParams(-1,-1);//填充整个父集容器
        lp.setMargins(10,10,0,0);
        addView(label,lp);
        setNum(0);
    }

    private int num  = 0;//格子中的数字

    private TextView label;
    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
        if(num<=0){
            label.setText("");
        }else {
            label.setText(num + "");     //setText(int) 识别为字符串资源的ID
        }
    }

}
